<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
    <h1>axios创建实例</h1>
    <button id="btn">提交按钮</button>


    <script>
        const oBtn  = document.querySelector('#btn')
        //创建一个axios实例，配置这个实例
        const myAxios = axios.create({
            baseURL: "/", //配置公共路径
            timeout: 10000, //配置超时事件
            headers: {} //配置请求头
        })
        oBtn.onclick =async function(){
            console.log('1');
          const re = await myAxios.get('/user',{
                params:{
                    userId : '001'
                }
            })
            console.log(re.data,'re');
        }
    </script>
</body>
</html>